<template>
  <view class="html-games-container">
    <!-- 页面标题 -->
    <view class="page-header">
      <view class="header-left" @tap="goBack">
        <i class="fas fa-arrow-left"></i>
      </view>
      <view class="header-title">HTML 游戏</view>
      <view class="header-right"></view>
    </view>

    <!-- 游戏列表 -->
    <view class="games-list">
      <view 
        v-for="game in games" 
        :key="game.id" 
        class="game-card" 
        @tap="launchGame(game)"
      >
        <view class="game-icon" :class="game.iconClass">
          <i :class="game.icon"></i>
        </view>
        <view class="game-info">
          <view class="game-name">{{ game.name }}</view>
          <view class="game-description">{{ game.description }}</view>
          <view class="game-type">{{ game.type }}</view>
        </view>
        <view class="game-arrow">
          <i class="fas fa-chevron-right"></i>
        </view>
      </view>
    </view>

    <!-- 说明区域 -->
    <view class="info-section">
      <view class="info-title">
        <i class="fas fa-info-circle"></i>
        游戏说明
      </view>
      <view class="info-content">
        <p>• 这些是原生HTML游戏，在uni-app中通过web-view组件运行</p>
        <p>• 支持与uni-app的双向通信</p>
        <p>• 游戏进度和分数可以同步到应用</p>
      </view>
    </view>
  </view>
</template>

<script>
import { goToWebView } from '@/utils/navigation';

export default {
  data() {
    return {
      games: [
        {
          id: 'block-collector',
          name: '方块收藏家',
          description: '点击出现的方块得分，挑战你的反应速度',
          type: '休闲游戏',
          icon: 'fas fa-cube',
          iconClass: 'bg-blue-100 text-blue-500',
          path: '/static/html/block-collector-game/index.html'
        },
        {
          id: 'roguelike-toy',
          name: '玩具冒险',
          description: '一个玩具的肉鸽冒险之旅，击败敌人获得经验',
          type: 'RPG游戏',
          icon: 'fas fa-dragon',
          iconClass: 'bg-purple-100 text-purple-500',
          path: '/static/html/roguelike-toy-game/index.html'
        }
      ]
    };
  },
  methods: {
    goBack() {
      uni.navigateBack();
    },
    launchGame(game) {
      goToWebView(game.path, game.name);
    }
  }
};
</script>

<style scoped>
.html-games-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-left {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-size: 18px;
}

.header-title {
  color: white;
  font-size: 18px;
  font-weight: bold;
}

.header-right {
  width: 40px;
}

.games-list {
  padding: 20px;
}

.game-card {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.game-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.game-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-right: 15px;
  flex-shrink: 0;
}

.game-info {
  flex: 1;
}

.game-name {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.game-description {
  font-size: 14px;
  color: #666;
  margin-bottom: 5px;
  line-height: 1.4;
}

.game-type {
  font-size: 12px;
  color: #999;
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.game-arrow {
  color: #ccc;
  font-size: 16px;
}

.info-section {
  margin: 20px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.info-title {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
}

.info-title i {
  margin-right: 8px;
  color: #667eea;
}

.info-content p {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  margin-bottom: 8px;
}

.info-content p:last-child {
  margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .game-card {
    padding: 15px;
  }
  
  .game-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .game-name {
    font-size: 16px;
  }
  
  .game-description {
    font-size: 13px;
  }
}
</style> 